#include<iostream>
#include<pthread.h>


class Mutex
{
public:
    Mutex(pthread_mutex_t* mutex)
    :_mutex(mutex)
    {
        //构造的时候就直接加锁
        pthread_mutex_lock(_mutex);
    }
    ~Mutex()
    {
        //析构的时候就解锁
        pthread_mutex_unlock(_mutex);
    }

private:
    pthread_mutex_t* _mutex;
};